﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;
using System.IO;

namespace UtopianGame.graphics.menu
{
    class PolicyScreen : BaseMenu
    {
      //  private String message;
        Rectangle Policy_textbox;
        Rectangle text;
        Texture2D myColour;
        Texture2D myColour2;
        public int currentPolicy;
       
        public PolicyScreen(ContentManager cm, String newMessage)
        {
            init(cm, newMessage);
           
        }
        protected void init(ContentManager cm, String newMessage)
        {
            base.init(cm);
            spriteName = "policyScreen";
            sprite = cm.Load<Texture2D>(spriteName);
            boundingBox.Width = 750;
            boundingBox.Height = 550;
            //sets size of textbox
            Policy_textbox = new Rectangle(150, 150, 500, 200);
            spriteName = "Textbox1";
            myColour = cm.Load<Texture2D>(spriteName);
            currentPolicy = 0;
           
            int centerAlignmentNumber = 0;
            //Reserve Button
            /*centerAlignmentNumber = boundingBox.X + (boundingBox.Width / 2);
            centerAlignmentNumber -= ((int)(GlobalDataHolder.baseFont.MeasureString("Reserve").X) / 2);
            //displays button
            addToSubObjectList(new ReserveButton(contentManager), 725, 210, 370);*/

            //Implement Button
            centerAlignmentNumber = boundingBox.X + (boundingBox.Width / 2);
            centerAlignmentNumber -= ((int)(GlobalDataHolder.baseFont.MeasureString("Implement").X) / 2);
            //displays button
            addToSubObjectList(new ImplementButton(contentManager), 725, 260, 500);

            //Next Button
            addToSubObjectList(new NextButton(contentManager), 550, 350, 500);

            //PreviousButton
            addToSubObjectList(new PreviousButton(contentManager), 375, 350, 500);

           /* //Cancel Button
            centerAlignmentNumber = boundingBox.X + (boundingBox.Width / 2);
            centerAlignmentNumber -= ((int)(GlobalDataHolder.baseFont.MeasureString("Cancel").X) / 2);
            //displays button
            addToSubObjectList(new CancelButton(contentManager), 150, 500, 500);*/

            //Close button in the center of screen
            centerAlignmentNumber = boundingBox.X + (boundingBox.Width / 2);
            centerAlignmentNumber -= ((int)(GlobalDataHolder.baseFont.MeasureString("Close").X) / 2);

            addToSubObjectList(new CloseMenuButton(contentManager), centerAlignmentNumber, 500, 500);

            //Add region buttons
            addToSubObjectList(new Region_Button1(contentManager), 590, 400, 500);
            addToSubObjectList(new Region_Button2(contentManager), 650, 364, 500);
            addToSubObjectList(new Region_Button3(contentManager), 710, 400, 500);
            addToSubObjectList(new Region_Button4(contentManager), 590, 470, 500);
            addToSubObjectList(new Region_Button5(contentManager), 650, 436, 500);
            addToSubObjectList(new Region_Button6(contentManager), 710, 470, 500);
            addToSubObjectList(new Region_Button7(contentManager), 650, 508, 500);
            
        }
           
        public override void draw(SpriteBatch sb)
        {
            base.draw(sb);

            //centerAlignmentNumber is used to dynamically center text on top of the menu
            int centerAlignmentNumber = 0;
            centerAlignmentNumber = boundingBox.X + (boundingBox.Width / 2);
            //centerAlignmentNumber -= ((int)(GlobalDataHolder.baseFont.MeasureString(message).X) / 2);
            //sb.DrawString(GlobalDataHolder.baseFont, message, new Microsoft.Xna.Framework.Vector2(centerAlignmentNumber, boundingBox.Y + 8), Color.Black);
            //sb.DrawString(GlobalDataHolder.baseFont, "Policy List", new Microsoft.Xna.Framework.Vector2(160, 100), Color.Black);
            sb.Draw(myColour, Policy_textbox, Color.White);
            //sb.Draw(myColour2, text, Color.White);

            //Draw policy name and description
            sb.DrawString(GlobalDataHolder.baseFont, Nation.policyList[currentPolicy].xmlData.name, new Vector2(Policy_textbox.X + 24, Policy_textbox.Y + 8), Color.Black);
            sb.DrawString(GlobalDataHolder.baseFont, Nation.policyList[currentPolicy].xmlData.description, new Vector2(Policy_textbox.X + 24, Policy_textbox.Y + 32), Color.Black);
            
            // sb.DrawString(GlobalDataHolder.baseFont,GlobalDataHolder.policyArray[0].name,new Microsoft.Xna.Framework.Vector2(160,200),Color.Black);
            //sb.DrawString(GlobalDataHolder.baseFont, GlobalDataHolder.policyArray[0].description, new Microsoft.Xna.Framework.Vector2(160, 250), Color.Black);
            string policyNumber = (currentPolicy+1) + "/" + Nation.policyList.Count;
            sb.DrawString(GlobalDataHolder.baseFont, policyNumber, new Microsoft.Xna.Framework.Vector2(490, 350), Color.White);
        }


    }
}
